package com.sushengren.easyword.model;

import com.sushengren.easyword.enums.DataTypeEnum;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.List;

/**
 * 写入数据
 *
 * @author sushengren
 */
@Getter
@Setter
@NoArgsConstructor
public class WriteData {

    /**
     * 写入标识
     */
    private String key;

    /**
     * 数据类型
     */
    private DataTypeEnum dataType;

    /**
     * 字符串值
     */
    private String stringValue;

    /**
     * 列表值
     */
    private List<List<WriteData>> listValue;

    /**
     * 值
     */
    private Object value;

    public WriteData(String stringValue) {
        this.value = stringValue;
        this.dataType = DataTypeEnum.STRING;
        this.stringValue = stringValue;
    }

    public WriteData(String key, String stringValue) {
        this.key = key;
        this.value = stringValue;
        this.dataType = DataTypeEnum.STRING;
        this.stringValue = stringValue;
    }

    public WriteData(String key, String stringValue, DataTypeEnum dataType) {
        this.key = key;
        this.value = stringValue;
        this.dataType = dataType;
        this.stringValue = stringValue;
    }

    public static WriteData emptyString(String key) {
        return new WriteData(key, "");
    }

}
